function AccountController(model, view) {
	this.model = model;
	this.view = view;
	
	var ac = this;
	
        
	this.init = function() {
		this.model.load(this.view.loadGreed);
		$('.account_edit_action').live("click", function(){
			ac.editRowAction(this);
		});
		$('.account_delete_action').live("click", function(){
			ac.delRowAction(this);
		});
		$('#account_form_send').click(function(){
			ac.formRowAction(this);
		});
	},
	
	
	this.editRowAction = function(e) {
            	var str = "edit_";
	    var id = $(e).attr('id').substr(str.length);
		
		var list = this.model.getList();
                var roles = this.model.getRoles();
		/*$("#account_form_fname").val($("#td_fname_"+id).html());
                $("#account_form_lname").val($("#td_lname_"+id).html());
		$("#account_form_email").val($("#td_email_"+id).html());
                $("#account_form_zip").val($("#td_zip_"+id).html());
                $("#account_form_gender").val($("#td_gender_"+id).html());
                */
               this.view.showRow(list[id], roles);
        
                
	},
	
	/*
	 *
	 */
	this.formRowAction = function() {
		
		var item = new Object();
		item['fname'] = $("#account_form_fname").val();
        item['lname'] = $("#account_form_lname").val();
		item['email'] = $("#account_form_email").val();
        item['zip'] = $("#account_form_zip").val();
        item['gender'] = $("#account_form_gender").val();
        item['role'] = $("#account_form_role").val();
		
		var action = $("#account_form_action").val();
		if (action == "edit") {
			item['id'] = $("#account_form_id").val();
			this.model.edit(item, this.view.editRow);
			
		} else if (action == "add") {
			this.model.add(item, this.view.addRow);
		} 
		
        $("#account_form_fname").val("");
        $("#account_form_lname").val("");
		$("#account_form_email").val("");
        $("#account_form_zip").val("");
        $("#account_form_gender").val("");
                
		$("#account_form_action").val("add");
		$("#account_form_id").val("");

	},
	
	
	
	this.delRowAction = function(e) {
		var str = "delete_";
	    var id = $(e).attr('id').substr(str.length);
		
		this.model.del(id, this.view.delRow);
                
                
	}
	
}

